home *** CD-ROM | disk | FTP | other *** search
/ Teach Your Children: Road Construction Ahead / Teach Your Children: Road Construction Ahead.iso / pc / rca / road.dxr / 00128_buttonHandlers.ls < prev    next >
Encoding:
Text File  |  1996-07-17  |  1.9 KB  |  78 lines

  1. global gFlushObject
  2.  
  3. on buttonHandler
  4.   set thisButton to the castNum of sprite the clickOn
  5.   set the castNum of sprite the clickOn to thisButton + 1
  6.   updateStage()
  7.   startTimer()
  8.   set pressed to 1
  9.   repeat while the mouseDown
  10.     if rollOver(the clickOn) then
  11.       if pressed = 0 then
  12.         set the castNum of sprite the clickOn to thisButton + 1
  13.         updateStage()
  14.         set pressed to 1
  15.       end if
  16.       next repeat
  17.     end if
  18.     if pressed = 1 then
  19.       set the castNum of sprite the clickOn to thisButton
  20.       updateStage()
  21.       set pressed to 0
  22.     end if
  23.   end repeat
  24.   if pressed = 1 then
  25.     repeat while the timer < 20
  26.     end repeat
  27.     set the castNum of sprite the clickOn to thisButton
  28.     updateStage()
  29.   end if
  30.   return pressed
  31. end
  32.  
  33. on toggleButtonHandler
  34.   set thisButton to the castNum of sprite the clickOn
  35.   set the castNum of sprite the clickOn to thisButton + 1
  36.   updateStage()
  37.   set pressed to 1
  38.   repeat while the mouseDown
  39.     if rollOver(the clickOn) then
  40.       if pressed = 0 then
  41.         set the castNum of sprite the clickOn to thisButton + 1
  42.         updateStage()
  43.         set pressed to 1
  44.       end if
  45.       next repeat
  46.     end if
  47.     if pressed = 1 then
  48.       set the castNum of sprite the clickOn to thisButton
  49.       updateStage()
  50.       set pressed to 0
  51.     end if
  52.   end repeat
  53.   return pressed
  54. end
  55.  
  56. on buttonBarHandler barType, howManyButtons, size, border
  57.   if barType = #Vertical then
  58.     set input to the mouseV - the top of sprite the clickOn + 1
  59.   else
  60.     set input to the mouseH - the left of sprite the clickOn + 1
  61.   end if
  62.   set total to size + border
  63.   set choice to howManyButtons
  64.   repeat with x = 1 to howManyButtons - 1
  65.     set max to x * total
  66.     if input <= max then
  67.       if input <= (max - border) then
  68.         set choice to x
  69.       else
  70.         set choice to 0
  71.       end if
  72.       exit repeat
  73.     end if
  74.   end repeat
  75.   flushBuffer()
  76.   return choice
  77. end
  78.